IT Technical Support for Developers

Tally Request XMLs

Share

Tally Integration, Tally ERP 9 Integration with Node.JS

Tally ERP Data Accessing via Node.js

Getting Tally ERP data using Server side javascript (node.js)
1. Create a NodeJS, express application
2. Install necessary plugins such as cors,xml,body-parser and request.

Server.js

var express = require('express');
var router = express.Router();
var bodyParser = require('body-parser');
var cors = require('cors');
var request = require('request');
require('body-parser-xml')(bodyParser);
var xml = require('xml');
var async = require('async');
/*Tally xml query*/
var xmlstring = '<ENVELOPE>
<HEADER>
<TALLYREQUEST>Export DATA</TALLYREQUEST>
</HEADER>
<BODY>
<EXPORTDATA>
<REQUESTDESC>
<REPORTNAME>LIST of Companies</REPORTNAME>
<STATICVARIABLES>
<SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
</STATICVARIABLES>
</REQUESTDESC>
</EXPORTDATA> </BODY>
</ENVELOPE>';
let app = express();
app.use(bodyParser.json());
/* use CORS to avoid net::ERR_CONNECTION_RESET */
app.use(cors);
app.post("/",(req,res) =>{ /*
Dynamic Tally xml Query parameter
const dbrequest = req.body.datarequest;
const params = req.body.params;
*/
var options = {
uri: 'http://localhost:9000',

method: 'POST',

headers: { 'Content-Type': 'text/xml;
charset:UTF-8',
'Content-Length': Buffer.byteLength(xmlstring)},
body: req.body.xmlstr
};
var result="";
async.parallel([
function(callback) {
/* tally data fetch from local tally server*/
var url = "http://localhost:9000";
request(options, function(err, response, body) {
// JSON body
if(err) { console.log(err);
callback(true);
return;
}

result = body;
callback(false, body);
});

}

],function(err, results) {
if(err) { console.log(err);
res.send(500,"Server Error");
return;
}
res.send("result--->"+result);
}
);
}

app.listen(4000,'localhost');
Hits: 4787, Rating : ( 5 ) by 1 User(s).